package com.ktjy.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class IntermediaryImpl implements InvocationHandler {


    private Object target;

    public IntermediaryImpl(Object object) {
        this.target = object;
    }


    public void singBegin() {
        System.out.println("准备工作");
    }

    public void singEnd() {
        System.out.println("结束工作");
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        singBegin();
        Object str = method.invoke(target, args);
        singEnd();
        return "谢谢:" + str;
    }
}
